{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/weike/template/web/common_nav'}
    <div class="panel panel-info">
        <div class="panel-heading">客片数量：<span style="color: red">{$page_total}</span> &nbsp;&nbsp;好友达标数量：<span style="color: red">{$count_limit_num}</span></div>
        <div class="panel-body">
            <form id="myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="weike.index.main" id="r" />
                <div class="form-group">
                    {if count($themelist)>1 }
                    <div class="col-xs-12 col-sm-2 col-md-2">
                        <select onchange="submitForm();" class="form-control" name="themeid">
                            {loop $themelist $row}
                            <option value="{$row['id']}" {if $themeid == $row['id'] } selected="selected" {/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                            {/loop}
                        </select>
                    </div>
                    {else}
                     <input type="hidden" name="themeid" value="{$themeid}" />
                    {/if}
                </div>

                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-4 col-xs-4 col-md-4">
                        <input class="form-control" name="search_data" placeholder="输入客户姓名" type="text" value="{$_P['search_data']}">
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                </div>
            </form>
<!--            <div class="col-sm-3 col-lg-1 col-md-3 col-xs-6">-->
<!--                <a href="{php echo createWebUrlPlugin('weike.index.addpage',array('themeid'=>$themeid));}" >-->
<!--                    <button class="btn btn-info" >新增客片</button>-->
<!--                </a>-->
<!--            </div>-->
        </div>
    </div>

    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                        <tr>
                            <th style="width: 50px">ID</th>
                            <th style="width: 100px">客户姓名</th>
                            <th style="width: 100px">打call数</th>
                            <th style="width: 100px">礼物数</th>
                            <th style="width: 100px">金币数</th>
                            <th style="width: 100px">浏览量</th>
                            <th style="width: 100px">打call客资</th>
                            <th style="width: 100px">打赏客资</th>
                            <th style="width: 100px">好友数量</th>
                            <th style="width: 100px">剩余天数</th>
                            <th style="width: 100px">礼品兑换</th>
                            <th style="width: 100px">制作日期</th>
                            <th style="width: 100px">结束日期</th>
                            <th style="width: 100px">绑定状态</th>
                            <th style="width: 100px">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {loop $list $index $item}
                        <tr>
                            <td>{$item['id']}</td>
                            <td>{$item['name']}</td>
                            <td>
                                <a href="{php echo createWebUrlPlugin('weike.call.listinfo',array('themeid'=>$themeid,'wk_id'=>$item['id']));}" title="查看明细"><span class="label label-warning">{$item['call_num']}</span></a>
                            </td>
                            <td>
                                <a href="{php echo createWebUrlPlugin('weike.gift.listinfo',array('themeid'=>$themeid,'wk_id'=>$item['id']));}" title="查看明细"><span class="label label-warning">{$item['gift_num']}</span></a>
                            </td>
                            <td>
                                <a href="{php echo createWebUrlPlugin('weike.gift.listinfo',array('themeid'=>$themeid,'wk_id'=>$item['id']));}" title="查看明细"><span class="label label-warning">{$item['money']}</span></a>
                            </td>
                            <td>{$item['page_view']}</td>
                            <td>
                                {if $item['config']['collect_ids'] && !empty($item['config']['collect_ids'])}
                                <a href="{php echo createWebUrl('fans_other_info',array('op' => 'display','themeid'=>$themeid,'uids'=>implode(',',$item['config']['collect_ids'])));}" title="查看明细"><span class="label label-success">{$item['collect_num']}</span></a>
                                {else}
                                <a href="{php echo createWebUrl('fans_other_info',array('op' => 'display','themeid'=>$themeid));}" title="查看明细"><span class="label label-success">{$item['collect_num']}</span></a>
                                {/if}
                            </td>
                            <td>
                                {if $item['config']['gift_collect_ids'] && !empty($item['config']['gift_collect_ids'])}
                                <a href="{php echo createWebUrl('fans_other_info',array('op' => 'display','themeid'=>$themeid,'uids'=>implode(',',$item['config']['gift_collect_ids'])));}" title="查看明细"><span class="label label-success">{$item['gift_collect_num']}</span></a>
                                {else}
                                <a href="{php echo createWebUrl('fans_other_info',array('op' => 'display','themeid'=>$themeid));}" title="查看明细"><span class="label label-success">{$item['gift_collect_num']}</span></a>
                                {/if}
                            </td>
                            <td>
                                {if $item['config']['friend_ids'] && !empty($item['config']['friend_ids'])}
                                <a href="{php echo createWebUrl('fans',array('op' => 'display','themeid'=>$themeid,'uids'=>implode(',',$item['config']['friend_ids'])));}" title="查看明细"><span class="label label-success">{$item['friend_num']}</span></a>
                                {else}
                                <a href="{php echo createWebUrl('fans',array('op' => 'display','themeid'=>$themeid));}" title="查看明细"><span class="label label-success">{$item['friend_num']}</span></a>
                                {/if}
                            </td>
                            <td>{$item['left_days']}</td>
                            <td>
                                {$item['case_gift_desc']}
                            </td>
                            <td>{php echo $item['created_at'];}</td>
                            {if $item['config'] && $item['config']['end_time']}
                            <td>{php echo $item['config']['end_time'];}</td>
                            {else}
                            <td>未设置</td>
                            {/if}
                            {if $item['uid'] }
                            <td >
                                <img src="{php echo tomedia($item['avatar']);}" width="28" style="border-radius: 3px;"><br>
                                {$item['nickname']}
                            </td>
                            {else}
                            <td >未绑定</td>
                            {/if}
                            <td>
                                <a class="btn btn-primary btn-sm" style="width: 35px"  data-type="edit" href="{php echo createWebUrlPlugin('weike.index.addpage',array('themeid'=>$themeid,'wk_id'=>$item['id']));}"
                                   title="编辑" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil-square-o"> </i></a>
                                <a class="btn btn-danger btn-sm" style="width: 35px"  data-type="delete" onclick="deleteInfo({$item['id']})"
                                   title="删除" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                                {if $item['uid'] && $item['left_days'] !== '已结束'}
                                <a class="btn btn-warning btn-sm btn-sm" style="width: 35px"  data-type="delete" onclick="removeBind({$item['id']})"
                                   title="重置绑定" data-toggle="tooltip" data-placement="top"><i class="fa fa-undo"> </i></a>
                                {/if}
                            </td>
                        </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

{$pager}
<script type="text/javascript">
    $(document).ready(
        function (){
            console.log('js代码');
        }
    );
    function submitForm(){
        $("#r").val('weike.index.main');
        var form = document.getElementById("myform");
        form.submit();
    }
    function removeBind(id) {
        layer.confirm('确定进行解绑操作？',{
            btn:['确定']
        },function () {
            let postUrl = "{php echo createWebUrlPlugin('weike.index.removeBind',array('themeid'=>$themeid));}";
            let success_redirect = "{php echo createWebUrlPlugin('weike.index.main',array('themeid'=>$themeid));}";
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data:{'wk_id':id},
                success:function (e) {
                    let status = e.status;
                    let result = e.result;
                    if (status!=1){
                        layer.msg(result.message)
                    }else{
                        layer.msg(result.message);
                        window.location.href = success_redirect;
                    }
                },
                fail:function (err) {
                    console.log(err)
                }
            })
        })
    }
    function deleteInfo(id) {
        layer.confirm('确定删除？',{
            btn:['确定']
        },function () {
            let postUrl = "{php echo createWebUrlPlugin('weike.index.deleteInfo',array('themeid'=>$themeid));}";
            let success_redirect = "{php echo createWebUrlPlugin('weike.index.main',array('themeid'=>$themeid));}";
            $.ajax({
                url:postUrl,
                dataType:'json',
                method:'post',
                data:{'wk_id':id},
                success:function (e) {
                    let status = e.status;
                    let result = e.result;
                    if (status!=1){
                        layer.msg(result.message)
                    }else{
                        layer.msg(result.message);
                        window.location.href = success_redirect;
                    }
                },
                fail:function (err) {
                    console.log(err)
                }
            })
        })
    }
</script>
